//
//  ZHCateogryPartViewController.m
//  LBProjectCategoryViewController_Example
//
//  Created by luckyRoy on 2017/12/21.
//  Copyright © 2017年 luckyBoyRoy@163.com. All rights reserved.
//

#import "ZHCateogryPartViewController.h"
#import <LBNewCategoryMainView.h>
#import <Masonry.h>

@interface ZHCateogryPartViewController ()

@property (nonatomic, strong) LBNewCategoryMainView *mainView;

@end

@implementation ZHCateogryPartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.mainView];
    
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(64);
        make.left.bottom.right.equalTo(self.view);
    }];
}

- (LBNewCategoryMainView *)mainView
{
    if (!_mainView) {
        __weak __typeof(&*self)weakSelf = self;
        _mainView = [[LBNewCategoryMainView alloc]initWithFrame:self.view.bounds isSingleSelected:NO CodeArray:self.selelectedCodeArray codeType:LBCategoryBizCodeTypePublicRequirement maxSelectedLevel:4 complete:^(NSArray<LBCategoryModel *> *modelArray, id parm) {
            if (weakSelf.viewBlock) {
                weakSelf.viewBlock(modelArray, parm);
            }
            [weakSelf.selelectedCodeArray removeAllObjects];
            [modelArray enumerateObjectsUsingBlock:^(LBCategoryModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                if (obj.code.length) {
                    [weakSelf.selelectedCodeArray addObject:obj.code];
                }
            }];
            [weakSelf.navigationController popToViewController:self animated:NO];
            [weakSelf.navigationController popViewControllerAnimated:YES];
        }];
    }
    return _mainView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
